package com.hlw.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.hlw.dao.UserMapper;
import com.hlw.entity.User;
import com.hlw.service.IUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mht
 * @since 2020-05-17
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

	@Resource
	private UserMapper userMapper;
	
	@Override
	public List<User> findAll() {
		
		return userMapper.selectList(null);
	}

	@Override
	public Integer updateStatus(Integer id, Integer status) {
		return userMapper.updateStatus(id, status);
		
	}

	@Override
	public String loginNameAndPwd(String loginname, String pwd,String npwd) {
		User user = userMapper.checkNameAndPwd(loginname, pwd);
		if(user!=null){
			
			userMapper.updatePwd(loginname, npwd);
			return "success";
			
		}else{
			String tip ="原始密码错误，请重新输入";
			return tip;
			
		}
		
		
	}

	@Override
	public User findUserByloginName(String loginname) {
		// TODO Auto-generated method stub
		return userMapper.findByName(loginname);
	}

}
